<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head th:replace="template/dashboard :: head('Tokens')">
    <!-- This block will be replaced by template. -->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <!-- Main Header -->
    <header class="main-header" th:replace="template/dashboard :: main-header">
        <!-- This block will be replaced by template. -->
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar" th:replace="template/dashboard :: main-sidebar">
        <!-- This block will be replaced by template. -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                <h1>Clients - Tokens List</h1>
                <p>All the tokens are listed here.</p>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#" th:href="@{/}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
                <li class="active">Token List</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">

            <!-- Your Page Content Here -->

            <div class="row">
                <div class="col-md-12">
                    <div class="alert alert-success" th:if="${param['revoke-success']}">
                        好嘞，Token被revoke了。
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                    <div class="alert alert-warning" th:if="${param['revoke-empty']}">
                        饿，没有Token被revoke。
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                </div>
            </div>

            <div class="row" th:each="client : ${tokens}">
                <div class="col-md-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title" th:inline="text">Tokens for client: [[ ${ client.key } ]]</h3>
                        </div>
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <tr>
                                    <th>#</th>
                                    <th>User</th>
                                    <th>Token</th>
                                    <th>Type</th>
                                    <th>Is Expired</th>
                                    <th>Expiration</th>
                                    <th>Expires In</th>
                                    <th>Scopes</th>
                                    <th>refreshToken</th>
                                    <th>Action</th>
                                </tr>
                                <tr th:each="token, iterStat : ${client.value} ">
                                    <td th:text="${iterStat.count}">#</td>
                                    <td th:text="${token.additionalInformation.user_name}">User</td>
                                    <td th:text="${token.value}">Token</td>
                                    <td th:text="${token.tokenType}">Type</td>
                                    <td th:text="${token.expired}">isExpired</td>
                                    <td th:text="${token.expiration}">expiration</td>
                                    <td th:text="${token.expiresIn}">Expires In</td>
                                    <td th:text="${token.scope}">Scopes</td>
                                    <td th:text="${token.refreshToken}">refreshToken</td>
                                    <td>
                                        <form th:action="@{/oauth/tokens/revoke}" method="post">
                                            <input type="hidden" name="user" th:value="${token.additionalInformation.user_name}" />
                                            <input type="hidden" name="token" th:value="${token.value}" />
                                            <button type="button" class="btn btn-danger btn-revoke"
                                                    th:attr="data-url=@{/oauth/tokens},data-username=${token.additionalInformation.user_name},data-token=${token.value}">Revoke</button>
                                        </form>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Main Footer -->
    <footer class="main-footer" th:replace="template/dashboard :: main-footer">
        <!-- This block will be replaced by template. -->
    </footer>

    <th:block th:replace="template/dashboard :: control-sidebar">
        <!-- This block will be replaced by template. --></th:block>
</div>
<!-- ./wrapper -->

<th:block th:replace="template/dashboard :: required-js-scripts">
    <!-- This block will be replaced by template. -->
</th:block>
<!-- clientDetails -->
<script src="" th:src="@{/resource/js/tokens.js}"></script>

<script type="text/javascript">
    $(function() {
       activeMenus('Token 管理')
    });
</script>
</body>
</html>
